import { Component, OnInit } from '@angular/core';

// 引入Router
// 事件跳转get路由还需引入NavigationExtras
import { Router,NavigationExtras } from '@angular/router';

@Component({
  selector: 'app-routermain',
  templateUrl: './routermain.component.html',
  styleUrls: ['./routermain.component.css']
})
export class RoutermainComponent implements OnInit {
// 声明
  constructor(public myrouter:Router) { }

  ngOnInit(): void {
  }
  goPage(){
    // 动态路由
    this.myrouter.navigate(['/router','我是动态路由的数据'])
  }
  goHome(){
    // 普通路由
    this.myrouter.navigate(['/home'])
  }
  goGet(){
    // Get路由
    // 定义传递的数据，并将类型指定为NavigationExtras
    let myqureyData:NavigationExtras = {
      queryParams:{
        name:'哇哈哈',
        age:12
      }
    }
    this.myrouter.navigate(['/routerget'],myqureyData)
  }
}
